package com.hex.ds.hdtp.core.web.script.transfer.controller;

import com.hex.ds.hdtp.core.app.common.page.dto.PageDto;
import com.hex.ds.hdtp.core.app.script.transfer.dto.request.ScriptVerifyLogRequestDto;
import com.hex.ds.hdtp.core.app.script.transfer.service.IScriptVerifyLogService;
import com.hex.ds.hdtp.core.web.common.page.PageVo;
import com.hex.ds.hdtp.core.web.common.page.converter.IPageVoAndPageDtoConverter;
import com.hex.ds.hdtp.core.web.script.transfer.converter.IScriptVerifyLogVoConverter;
import com.hex.ds.hdtp.core.web.script.transfer.vo.query.ScriptVerifyLogQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@Api(tags = "03-脚本迁移：脚本验证")
@RequestMapping("/api/script/convert/test/log")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ScriptVerifyLogController {

    private final IScriptVerifyLogService scriptTestLogService;

    private final IPageVoAndPageDtoConverter pageVoAndPageDtoConverter;

    private final IScriptVerifyLogVoConverter converter;

    @GetMapping
    @ApiOperation("脚本转换清单测试结果-分页查询")
    public ResponseEntity queryListByPage(ScriptVerifyLogQueryVo scriptVerifyLogQueryVo, PageVo pageVo) {
        log.info("进入到【ScriptConvertListTestController.queryListByPage】方法,参数：{}" + scriptVerifyLogQueryVo.toString());
        final PageDto pageDto = pageVoAndPageDtoConverter.toPageDto(pageVo);
        ScriptVerifyLogRequestDto requestDto = converter.toScriptTestLogRequestDto(scriptVerifyLogQueryVo);
        return ResponseEntity.ok(scriptTestLogService.queryListByPage(requestDto, pageDto));
    }
}
